package com.xinruke.hostels.dailymanage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.dailymanage.interfaces.dto.roomrepair.*;
import com.xinruke.hostels.dailymanage.service.RoomRepairRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/room/repair/record/")
@Api(tags = "房间维修日志")
@Slf4j
public class RoomRepairRecordController extends BaseController {

    @Autowired
    private RoomRepairRecordService roomRepairRecordService;

    @PostMapping(value = "/add")
    @ApiOperation("添加")
    public ResultVO<Integer> add(@RequestBody @Valid RoomRepairRecordAddDTO params){
        return roomRepairRecordService.add(params);
    }

    @PostMapping(value = "/repairComplete")
    @ApiOperation("维修完成")
    public ResultVO repairComplete(@RequestBody @Valid RoomRepairCompleteDTO params){
        return roomRepairRecordService.repairComplete(params);
    }

    @PostMapping(value = "/repairCancel")
    @ApiOperation("取消维修")
    public ResultVO repairCancel(@RequestBody @Valid RoomRepairCancelDTO params){
        return roomRepairRecordService.repairCancel(params);
    }

    @PostMapping(value = "/list")
    @ApiOperation(value = "查询房间维修记录列表")
    public ResultVO<RowsDataVO<RoomRepairRecordQueryResultDTO>> list(@Valid @RequestBody RoomRepairRecordQueryListDTO params) {
        return roomRepairRecordService.list(params);
    }

    @PostMapping(value = "/detail")
    @ApiOperation(value = "查询房间维修记录详情")
    public ResultVO<RoomRepairRecordQueryResultDTO> detail(@Valid @RequestBody RoomRepairRecordQueryDetailDTO params){
        return roomRepairRecordService.detail(params);
    }
}
